<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Edição de Funcionários</title>
	<h:outputScript name="scripts.js" library="js" />
</h:head>
<h:body>

	<h:form prependId="false" enctype="multipart/form-data">
		<h:messages id="messages" />

		<h:panelGrid columns="2">
			<f:facet name="header">Edição de Funcionários</f:facet>
			<f:facet name="footer">
				<div align="center">
					<h:commandButton action="#{funcionarioBean.cancelar()}" value="Cancelar" immediate="true" />
					<h:commandButton action="#{funcionarioBean.gravar()}" value="Gravar" />
				</div>
			</f:facet>

			<h:outputLabel value="ID" for="campo-id" />
			<h:inputText value="#{funcionarioBean.funcionario.id}" readonly="true" id="campo-id" />

			<h:outputLabel value="Nome" for="campo-nome" />
			<h:inputText value="#{funcionarioBean.funcionario.nome}" maxlength="40" size="40" id="campo-nome" />

			<h:outputLabel value="CPF" for="campo-cpf" />
			<h:inputText value="#{funcionarioBean.funcionario.cpf}" maxlength="14" size="14" id="campo-cpf" onkeydown="Mascara(this,Cpf);"
				onkeyup="Mascara(this, Cpf);" onkeypress="Mascara(this,Cpf);" />

			<h:outputLabel value="E-mail" for="campo-email" />
			<h:inputText value="#{funcionarioBean.funcionario.email}" maxlength="40" size="40" id="campo-email" />

			<h:outputLabel value="Salário" for="campo-salario" />
			<h:inputText value="#{funcionarioBean.funcionario.salario}" id="campo-salario" size="20" maxlength="20"
				onkeydown="Mascara(this,Valor);" onkeyup="Mascara(this, Valor);" onkeypress="Mascara(this,Valor);" />

			<h:outputLabel value="Nascimento" for="campo-nascimento" />
			<h:inputText value="#{funcionarioBean.funcionario.nascimento}" id="campo-nascimento" size="12" maxlength="12"
				onkeydown="Mascara(this,Data);" onkeyup="Mascara(this, Data);" onkeypress="Mascara(this,Data);">
				<f:converter converterId="converterCalendar" />
			</h:inputText>

			<h:outputLabel value="Ativo" for="campo-ativo" />
			<h:selectBooleanCheckbox value="#{funcionarioBean.funcionario.ativo}" id="campo-ativo" />

			<h:outputLabel value="Nome de usuário" for="campo-usuario" />
			<h:inputText value="#{funcionarioBean.funcionario.nomeUsuario}" id="campo-usuario" size="20" maxlength="20" />

			<h:outputLabel value="Senha" for="campo-senha" />
			<h:inputSecret value="#{funcionarioBean.funcionario.senha}" id="campo-senha" size="10" maxlength="10" redisplay="true" />

			<h:outputLabel value="Grupo" for="campo-grupo" />
			<h:selectOneMenu value="#{funcionarioBean.funcionario.grupo}" converter="#{funcionarioBean.converterGrupo}" id="campo-grupo">
				<f:selectItem itemLabel="Selecione um Grupo" noSelectionOption="true" />
				<f:selectItems value="#{grupoBean.listarTodos()}" />
			</h:selectOneMenu>

			<h:outputLabel value="Setor" for="campo-setor" />
			<h:selectOneMenu value="#{funcionarioBean.funcionario.setor}" converter="#{funcionarioBean.converterSetor}" id="campo-setor">
				<f:selectItem itemLabel="Selecione um Setor" noSelectionOption="true" />
				<f:selectItems value="#{setorBean.listarTodos()}" />
			</h:selectOneMenu>

			<h:outputLabel value="Foto" for="campo-foto" />
			<p:fileUpload id="campo-foto" mode="advanced" update="messages,campo-imagem" auto="true" label="Selecionar"
				fileUploadListener="#{funcionarioBean.enviarFoto}" />

			<h:outputLabel value="" for="campo-imagem" />
			<p:graphicImage value="#{funcionarioBean.funcionario.imagem}" id="campo-imagem" 
			style="width:100px; height:100px" cache="false" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
		</h:panelGrid>
	</h:form>
</h:body>
</html>
